home *** CD-ROM | disk | FTP | other *** search
- /* © 1988, Bowers Development Corp. */
- /* Scrolling.c */
-
- #include "Globals.h"
-
- #include "Scrolling.h"
-
-
- /*----------*/
- void ResizeScrollBars ()
- {
- short curTop;
- short curLeft;
- Rect portRect;
-
- portRect = curWindow->portRect;
- if (cur->vScroll != nil) {
- curTop = (**(cur->vScroll)).contrlRect.top;
- HideControl (cur->vScroll);
- MoveControl (cur->vScroll,
- (portRect.right + 1) - sBarWidth,
- curTop);
- SizeControl (cur->vScroll,
- sBarWidth,
- ((portRect.bottom + 1) - sBarWidth) + 1 - curTop);
- ShowControl (cur->vScroll);
- ValidRect (&(**(cur->vScroll)).contrlRect);
- }
-
- if (cur->hScroll != nil) {
- curLeft = (**(cur->hScroll)).contrlRect.left;
- HideControl (cur->hScroll);
- MoveControl (cur->hScroll,
- curLeft,
- (portRect.bottom + 1) - sBarWidth);
- SizeControl (cur->hScroll,
- ((portRect.right + 1) - sBarWidth) + 1 - curLeft,
- sBarWidth);
- ShowControl (cur->hScroll);
- ValidRect (&(**(cur->hScroll)).contrlRect);
- }
- } /*ResizeScrollBars*/
-
- /*----------*/
- void DoScrollPart (whichScroll, partCode)
- ControlHandle whichScroll;
- short partCode;
- {
- short pageSize;
- short delta;
- short oldValue;
-
- pageSize = GetCRefCon (whichScroll);
- switch (partCode) {
- case inUpButton:
- delta = -1;
- break;
- case inDownButton:
- delta = 1;
- break;
- case inPageUp:
- delta = -pageSize;
- break;
- case inPageDown:
- delta = pageSize;
- break;
- default:
- delta = 0;
- break;
- } /*switch*/
- if (delta != 0) {
- oldValue = GetCtlValue (whichScroll);
- SetCtlValue (whichScroll, oldValue + delta);
- }
- } /*DoScrollPart*/
-
- /*----------*/
- pascal void ActionGlue (ControlHandle whichScroll,
- short partCode);
- pascal void ActionGlue (whichScroll, partCode)
- ControlHandle whichScroll;
- short partCode;
- {
- short oldValue;
- short newValue;
- ProcPtr actionProc;
-
- oldValue = GetCtlValue (whichScroll);
- DoScrollPart (whichScroll, partCode);
- newValue = GetCtlValue (whichScroll);
- if (newValue != oldValue) {
- actionProc = (**whichScroll).contrlAction;
- CallPascal (newValue, oldValue, actionProc);
- }
- } /*ActionGlue*/
-
- /*----------*/
- void TrackScroll (whichScroll, partCode, where, actionProc)
- ControlHandle whichScroll;
- short partCode;
- Point where;
- ProcPtr actionProc;
- {
- short oldValue;
- short newValue;
-
- if (partCode == inThumb) {
- oldValue = GetCtlValue (whichScroll);
- partCode = TrackControl (whichScroll, where, nil);
- if (actionProc != nil) {
- newValue = GetCtlValue (whichScroll);
- CallPascal (newValue, oldValue, actionProc);
- }
- } else {
- if (actionProc == nil) {
- partCode = TrackControl (whichScroll, where, nil);
- DoScrollPart (whichScroll, partCode);
- } else {
- (**whichScroll).contrlAction = actionProc;
- partCode = TrackControl (whichScroll, where, (ProcPtr) &ActionGlue);
- }
- }
- } /*TrackScroll*/
-